import java.io.*;

public class ObjectInputStreamDemo15 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        FileOutputStream stream = new FileOutputStream("F:\\IdeaProjects\\MyJava230203\\day27\\dir\\6.t");
//        ObjectOutputStream objectOutputStream = new ObjectOutputStream(stream);
//        Dog dog = new Dog("哈士奇", 12);
//        objectOutputStream.writeObject(dog);
//        objectOutputStream.flush();
//        objectOutputStream.close();
//
        FileInputStream fileInputStream = new FileInputStream("F:\\IdeaProjects\\MyJava230203\\day27\\dir\\6.t");
        ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
        Dog dog = (Dog) objectInputStream.readObject();
        System.out.println(dog);
    }
}


class Dog implements Serializable {
    private String name;
    private int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}